function prm = bciExecuteGraspFeedback(prm)

isFinished = getRESI('isFinished','finished');
if prm.gripperState <0, % first call
    isFinished = true;
    prm.gripperState = 0;
end
if ~isFinished,    
    return;
end
doVerbose=true;

switch prm.gripperState,
    case 0,
        % Grasp
        setRESI('startGrasping','idx',prm.currentObject);
        prm.gripperState = 1;
        if doVerbose, fprintf('Grasping started.\n');end
    case 1,
        %attach Object
        setRESI('attachObject','idx',prm.currentObject);
        if prm.objectRecognition==1,
            % finger grasp
            setRESI('startPhysicalGrasping');
            if doVerbose, fprintf('Physical grasping started.\n');end
        end
        % pick object
        setRESI('manipulateObject','action',1);
        if doVerbose, fprintf('Picked object.\n');end
        prm.gripperState = 2;
    case 2,
        % replace object
        setRESI('manipulateObject','action',2);
        if doVerbose, fprintf('Replaced object.\n');end
        prm.gripperState = 3;        
    case 3,
        if prm.objectRecognition==1,
            % reset finger
            setRESI('resetPhysicalGrasping');
            if doVerbose, fprintf('Reset physical grasping.\n');end
        end
        % detache
        setRESI('detachObject','idx',prm.currentObject);        
        if doVerbose, fprintf('Object released.\n');end
        % reset
        setRESI('resetGrasping');
        if doVerbose, fprintf('Grasping reset.\n');end
        prm.gripperState =4;        
    case 4,
        % default state reached
        prm.gripperState = 0;
        prm.readyForNextPrediction = true;
    otherwise
        warning('Undefined gripperState.');
end
